{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>text_a</th>\n",
       "      <th>text_b</th>\n",
       "      <th>socre</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>It depends on what you want to do next, and wh...</td>\n",
       "      <td>It's up to you what you want to do next.</td>\n",
       "      <td>4.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Wal-Mart, Kohl's Corp., Family Dollar Stores I...</td>\n",
       "      <td>Wal- Mart, Kohl's Corp., Family Dollar Stores ...</td>\n",
       "      <td>4.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>A girl in water without goggles or a swimming ...</td>\n",
       "      <td>A girl in water, with goggles and swimming cap.</td>\n",
       "      <td>3.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>If I understand you correctly, you are looking...</td>\n",
       "      <td>Inclusion is the act of including and exclusio...</td>\n",
       "      <td>2.60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>A Das Air Cargo plane sits on the runway.</td>\n",
       "      <td>A passenger plane parked on a runway.</td>\n",
       "      <td>3.20</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                              text_a  \\\n",
       "0  It depends on what you want to do next, and wh...   \n",
       "1  Wal-Mart, Kohl's Corp., Family Dollar Stores I...   \n",
       "2  A girl in water without goggles or a swimming ...   \n",
       "3  If I understand you correctly, you are looking...   \n",
       "4          A Das Air Cargo plane sits on the runway.   \n",
       "\n",
       "                                              text_b  socre  \n",
       "0           It's up to you what you want to do next.   4.00  \n",
       "1  Wal- Mart, Kohl's Corp., Family Dollar Stores ...   4.75  \n",
       "2    A girl in water, with goggles and swimming cap.   3.00  \n",
       "3  Inclusion is the act of including and exclusio...   2.60  \n",
       "4              A passenger plane parked on a runway.   3.20  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_df = pd.read_csv('../data/train.csv')\n",
    "train_df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>text_a</th>\n",
       "      <th>text_b</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Trans fats are created when hydrogen is added ...</td>\n",
       "      <td>Trans fats are created when vegetable oil has ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>In Russian, for example, animacy is not clear-...</td>\n",
       "      <td>As in Russian, Polish marks animate masculine ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>The answer to both questions is: Yes.</td>\n",
       "      <td>If the answer to any of these questions is yes...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Q: Can I buy coverage for prescription drugs r...</td>\n",
       "      <td>Congress has added a new benefit - an option t...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>New legit download service launches with PC us...</td>\n",
       "      <td>BuyMusic is the first subscription-free paid d...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                              text_a  \\\n",
       "0  Trans fats are created when hydrogen is added ...   \n",
       "1  In Russian, for example, animacy is not clear-...   \n",
       "2              The answer to both questions is: Yes.   \n",
       "3  Q: Can I buy coverage for prescription drugs r...   \n",
       "4  New legit download service launches with PC us...   \n",
       "\n",
       "                                              text_b  \n",
       "0  Trans fats are created when vegetable oil has ...  \n",
       "1  As in Russian, Polish marks animate masculine ...  \n",
       "2  If the answer to any of these questions is yes...  \n",
       "3  Congress has added a new benefit - an option t...  \n",
       "4  BuyMusic is the first subscription-free paid d...  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_df = pd.read_csv('../data/test.csv')\n",
    "test_df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def solve(row):\n",
    "    columns = ['text_a', 'text_b']\n",
    "    ans = row['text_a'] + row['text_b']\n",
    "    return ans    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "train_df['text'] = train_df.apply(lambda row: solve(row), axis=1)\n",
    "test_df['text'] = test_df.apply(lambda row: solve(row), axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "390\n"
     ]
    }
   ],
   "source": [
    "texts = train_df.text.tolist()\n",
    "max_len = 0\n",
    "df_len_list = []\n",
    "for i in range(len(texts)):\n",
    "    text = []\n",
    "    text = texts[i]\n",
    "#     if max_len < len(text):\n",
    "#         print(text)\n",
    "    df_len_list.append(len(text))\n",
    "    max_len = max(max_len, len(text))\n",
    "print(max_len)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "363"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sorted_len = sorted(df_len_list)\n",
    "sorted_len[int(len(sorted_len)*0.999)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "socre_list = train_df['socre'].to_list()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.0\n",
      "5.0\n"
     ]
    }
   ],
   "source": [
    "print(min(socre_list))\n",
    "print(max(socre_list))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
